//  Android Carpool System
//  2011-2011
//  Author: Jinhuan Wang
//  name:  PassageConfirm .java
//  description: provide methods to  allow passager confirm his choice
//$history: /carpoolservice/scr/com/carpool/service/PassageConfirm.java$
/*************************************************/
package com.carpool.service;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class PassageConfirm extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		DBOperation DBO = new DBOperation();
		int passagerID=0;
		int	driverID=0;
		int routeID=0;
		boolean ResultValue = false;
		try {
			InputStream is = request.getInputStream();
			DataInputStream dis = new DataInputStream(is);
			passagerID=dis.readInt();
			driverID=dis.readInt();	
			routeID=dis.readInt();
			ResultValue = DBO.confirm(passagerID,driverID,routeID);
			DataOutputStream dos = new DataOutputStream(response
					.getOutputStream());
			dos.writeBoolean(ResultValue);
			dos.flush();
			dos.close();
		} catch (Exception e) {
		}

	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		doPost(request, response);
	}

}
